package development.listener;

import state.socket.DataPackage;
import development.Constants;
import development.FrmDownloadResource;
import development.FrmLogin;
import development.Global;
import development.socket.SocketClientUtil;

public class ConnectionDoneListener extends Listener {
  public static boolean needAuthenAfterConnect = false;
  
  public ConnectionDoneListener() {
    super(ConnectionDoneListener.class.toString());
  }

  public void onConnectDone() {
    SocketClientUtil.checkForUpdate(Constants.VERSION, Global.provider.getId());
    ((FrmDownloadResource) FrmDownloadResource.instance()).message = "Đang kiểm tra phiên bản...";
    Global.authenticateHandle.removeListener(this);
    
    if (needAuthenAfterConnect) {
      needAuthenAfterConnect = false;
      if ((Global.systemCanvas.frmCurrent == Global.alert) && (Global.alert.getParent() == FrmLogin.instance())) {
        FrmLogin frmLogin = (FrmLogin) FrmLogin.instance();
        frmLogin.login();
      }
    }
  }

  public void onConnectFail() {
  }

  public void onDisconnect() {
  }

  public void onRecieveData(DataPackage dataPackage) {
  }
}
